/**
 * RemoteService.java
 */
package fss.remote;

import java.io.Serializable;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.Set;

import fss.common.communication.Request;
import fss.util.rmi.RmiId;

/**
 * An interface for remote services.
 * <p>
 * This interface will be the observer/subscriber that registers with
 * <code>ServiceRegistry</code> and receives commands and updates. 
 * 
 * @author thinh
 *
 */
public interface RemoteService extends Remote, Serializable {
    /**
     * Get the identifier for the service.
     * @return the id.
     * @throws RemoteException error with remote object.
     */
    public RmiId getId() throws RemoteException;
    /**
     * Set the registry that this service is registered to.
     * @param id the id.
     * @throws RemoteException error with remote object.
     */
    public void setRegistryId(RmiId id) throws RemoteException;
    /**
     * Get the registry id that this service is registered to.
     * @return the id.
     * @throws RemoteException error with remote object.
     */
    public RmiId getRegistryId() throws RemoteException;
    /**
     * The update method that gets invoked when the <code>Observable</code> notifies
     * all of its registered <code>Observer</code> objects. This object will
     * only process/handle the <code>message</code> that it cares about. 
     * 
     * @param observable the object that notified the remote service of change.
     * @param message the message, if applicable.
     * @throws RemoteException error communicating with remote object.
     */
    public void update(Object observable, Object message) throws RemoteException;
    /**
     * Stop this service.
     * @throws RemoteException error communicating with remote object.
     */
    public void stop() throws RemoteException;
    /**
     * Start this service.
     * @throws RemoteException error communicating with remote object.
     */
    public void start() throws RemoteException;
    /**
     * Get a set of registered client identifiers (no duplicates).
     * @return a set of registration identifiers.
     * @throws RemoteException error invoking the method.
     */
    public Set<RmiId> getRegisteredClientList() throws RemoteException;
    /**
     * Process a request.
     * <p>
     * When a request comes, the registry will try to notify its observer(s) that a
     * request came. Only the observers/subscribes will process the request.
     * @param request the request object.
     * @throws RemoteException remote invocation error.
     */
    public void processRequest(Request request) throws RemoteException;
}
